<template>
	<view class="settlement-page-box">

		<scroll-view class="settlement-scroll-box" scroll-y>
			<view class="settlement-scroll-content">

				<!-- 时间 -->
				<view class="settlement-list-box">
					<view class="settlement-list-more">
						<view class="settlement-list-time flex">
							<view style="color: #999">营业时间:</view>
							<view class="settlement-list-item">
								<view style="margin-left: 14rpx;font-size: 26rpx;" v-for="(item,index) in business_time" :key="index">{{item[0]}}-{{item[1]}};
								</view>
							</view>
						</view>
					</view>
					<view class="settlement-list-more" v-if="pickup_type==2">
						<view class="settlement-list-time flex">
							<view style="color: #999">配送时间:</view>
							<view class="settlement-list-item">
								<view style="margin-left: 14rpx;font-size: 26rpx;" v-for="(item,index) in send_time" :key="index">{{item[0]}}-{{item[1]}};
								</view>
							</view>
						</view>
						<view class="settlement-list-price-box" style="justify-content: flex-end;margin-top:10rpx;">
							<text class="settlement-list-small-text">起送价:</text>
							<text class="settlement-list-price">￥{{starting_price}}</text>
						</view>
					</view>

					<!-- 积分抵扣（基于订单） -->
					<view class="settlement-list"
						v-if="vip&&merchantConfig&&merchantConfig.integral_arrive_cash==1&&merchantConfig.marketing_methods==1&&max_use_integral>0&&max_integral_dis_money>0">
						<view class="settlement-list-title">
							<text>{{integral_name}}抵扣</text>
							<text class="settlement-list-integral-dis">￥{{integral_dis_money}}</text>
						</view>
						<view class="settlement-list-content">
							<view class="settlement-list-choose">
								<view class="settlement-integral-input">
									<input type="number" :placeholder="'最多' + max_use_integral + integral_name" @input="inputIntegral" :value="integral_dis_num"
										placeholder-class="placeholder-class"></input>
								</view>
							</view>
							<view class="settlement-list-choose" @tap="changeIntegralCash">
								<text :style="'color:' + (is_integral_cash==1?'#000':'#999')">{{integral_name}}抵现</text>
								<image :src="is_integral_cash==1?'/static/images/choose-circle-1.png':'/static/images/choose-circle-2.png'">
								</image>
							</view>
						</view>
					</view>
					<view class="settlement-list settlement-list-start">
						<view class="settlement-list-title">
							<text>配送方式</text>
						</view>
						<view class="settlement-list-content">
							<view class="settlement-list-content-column">
								<block v-for="(item,index) in pickup_list" :key="item.id">
									<view class="settlement-list-choose" @tap="sendMethod" :data-index="item.id">
										<text :style="'color:' + (pickup_type==item.id?'#000':'#999')">{{item.id==1?('到店'+item.name):item.name}}</text>
										<image :src="pickup_type==item.id?'/static/images/choose-circle-1.png':'/static/images/choose-circle-2.png'">
										</image>
									</view>
								</block>
							</view>
						</view>
					</view>
					<view class="settlement-list" v-if="pickup_type==1||pickup_type==2">
						<view class="settlement-list-title">
							<text>时间选择</text>
						</view>
						<view class="settlement-list-choose">
							<!-- #ifndef MP-ALIPAY -->
							<picker class="settlement-time-picker timer-picker-color" mode="multiSelector" @change="bindStartMultiPickerChange" @tap="pickerTap"
								@columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray">
								{{startDate==''?('点击选择'+(pickup_type==2?'起送':'自提')+'时间'):startDate}}
							</picker>
							<!-- #endif -->
							<!-- #ifdef MP-ALIPAY -->
							<uni-popup type="bottom" ref="popup" ::mask-click="false" :is-mask-click="false" style="background: rgba(255,255,255,1);"
								class="popup">
								<view class="operate">
									<view @click="successSelect" class="sure">完成</view>
								</view>
								<picker-view indicator-style="{height: 100rpx}" class="settlement-time-picker timer-picker-color" :value="multiIndex"
									@change="bindStartMultiPickerChange" style="background: rgba(255,255,255,1);">
									<picker-view-column v-for="(col,index) in  multiArray" :key="index">
										<view class="item" v-for="(item,i) in col" :key="i">{{item}}</view>
									</picker-view-column>
								</picker-view>
							</uni-popup>
							<view class="select-time" @click="showSelectTime">
								{{startDate==''?('点击选择'+(pickup_type==2?'起送':'自提')+'时间'):startDate}}
							</view>
							<!-- #endif -->
							<image class="settlement-list-choose-right" src="/static/images/arrow-right-1.png"></image>
						</view>
					</view>

				</view>

				<!-- 祝福语 -->
				<view class="settlement-list-box" v-if="blessinfo.status==1" style="padding:0">
					<view v-if="blessData.url" class="zhufu_bg_now">
						<view class="blesstitle">
							<text class="blessttext">{{blessData.type==1?'视频':'录音'}}</text>
							<text class="blessttext" style="color:#ccc" v-if="blessData.length">时长:{{blessData.length + 's'}}</text>
						</view>
						<view class="play_icon">
							<image class="play_pic" v-if="isPlaying" @click="toStop" src="/static/images/audio_play_end.png"></image>
							<image class="play_pic" @click="toPlay(blessData.type)" v-else src="/static/images/audio_play_start.png"></image>
							<view>
								<uni-icons @click="toEdit(blessData.type)" type="gear-filled" size="16" color="#ccc">
								</uni-icons>修改
								<uni-icons @click="deleteItem(blessData.type)" style="margin-left:20rpx" type="trash-filled" size="16" color="#ccc"></uni-icons>
								删除
							</view>
						</view>
					</view>
					<view class="zhufu_bg" v-else @click="toBlessing">
						<image style="width:100%;height:100%" :src="blessinfo.entrance_style"></image>
						<!-- <image style="width:100%;height:100%" src="https://lscs.mobxcx.com/Public/images/blessing_default.png"></image> -->
					</view>
				</view>

				<!-- 收货地址 -->
				<view class="settlement-list-box">
					<!-- 引入选择收货地址模板 -->
					<block v-if="pickup_type==2||pickup_type==3">
						<view class="settlement-list">
							<address-diy v-if='isShowAddress' :address.sync="address"></address-diy>
						</view>
						<view class="settlement-list">
							<block v-if="pickup_type==2">
								<view class="settlement-distance">范围: {{math/1000}}km</view>
								<view class="settlement-distance">距离: {{distance}}km</view>
							</block>
							<view class="settlement-distance"></view>
							<view class="settlement-list-price-box" v-if="isShowFee == 1">
								<text class="settlement-list-small-text">配送费:</text>
								<text class="settlement-list-price">￥{{delivery_fee}}</text>
							</view>
							<view class="settlement-list-price-box fee-throgh" v-if="isShowFee == 2">
								<text class="settlement-list-small-text">配送费:</text>
								<text class="settlement-list-price">￥{{delivery_fee}}</text>
							</view>
						</view>
						<view v-if="delivery_status == 1">
							<express-fee :delivery_cost="delivery_cost"></express-fee>
						</view>
					</block>
					<block v-if="pickup_type==1">
						<view class="settlement-list flexStart">
							<text>姓名</text>
							<input type="text" :value="link_name" @input="inputName" placeholder-class="pl" placeholder="联系人姓名"></input>
						</view>
						<view class="settlement-list flexStart">
							<text>手机号</text>
							<input type="number" :value="mobile_phone" maxlength="11" @input="inputPhone" placeholder-class="pl" placeholder="联系人手机号"></input>
						</view>
					</block>
				</view>

				<!-- 商品列表 -->
				<view class="settlement-list-box" v-if="goodsList.length>0">
					<view class="settlement-list" v-if="vip && userInfo.platform_type == 1">
						<view class="settlement-vip-box">
							<view class="settlement-vip">
								<text>会员卡：{{vip.card_num}}</text>
								<text>折扣：{{vip.discount? (vip.discount*100)/10 :""}}</text>
							</view>
							<view class="settlement-vip">
								<text>余额：{{vip.balance}}</text>
								<text>{{integral_name}}：{{vip.integral}}</text>
							</view>
							<view class="settlement-vip-tips">会员折扣: 10表示不打折，5表示打5折</view>
						</view>
					</view>

					<block v-for="(item, index) in goodsList" :key="index">
						<view class="settlement-list flexStart" @tap.stop="toGoodsDetail" :data-goods_id="item.goods_id">
							<view class="settlement-goods-img">
								<image mode="aspectFit" :src="item.goods_img"></image>
							</view>
							<view class="settlement-goods-con">
								<view class="settlement-goods-name">{{item.goods_name}}</view>
								<view class="settlement-goods-sku" v-if="item.sku_name">{{item.sku_name}}</view>
								<view class="settlement-goods-num">
									<text>x</text>
									<text>{{item.num}}</text>
								</view>
							</view>
							<view class="settlement-goods-price">
								<text v-if="item.promotion_status==1">￥{{item.act_price}}</text>
								<block v-else>
									<block v-if="item.plus_mem_status==1&&vip&&vip.user_type==2">
										<view class="settlement-goods-price-box">
											<text>￥{{item.plus_price}}</text>
											<text class="vip-price-style">Plus</text>
											<block
												v-if="item.plus_mem_integral>0 && merchantConfig&&merchantConfig.integral_arrive_cash==1&&merchantConfig.marketing_methods==2">
												<text class='plus-integral'>+{{item.plus_mem_integral}}{{integral_name}}</text>
											</block>
										</view>
										<view v-if="item.plus_mem_integral>0">
											<text class="origin-price">原价：</text>
											<text>￥{{item.online_price}}</text>
										</view>
									</block>
									<block v-else>
										<block v-if="item.shop_mem_status==1&&vip&&(vip.user_type==3 || item.plus_mem_status != 1&&vip.user_type==2)">
											<view class="settlement-goods-price-box">
												<text>￥{{item.shop_mem_price}}</text>
												<text class="vip-price-style">VIP</text>
												<block
													v-if="item.shop_mem_integral>0 && merchantConfig&&merchantConfig.integral_arrive_cash==1&&merchantConfig.marketing_methods==2">
													<text class="shop-mem-integral">+{{item.shop_mem_integral}}{{integral_name}}</text>
												</block>
											</view>
											<view v-if="item.shop_mem_integral>0">
												<text class="origin-price">原价：</text>
												<text>￥{{item.online_price}}</text>
											</view>
										</block>
										<text v-else>￥{{item.online_price}}</text>
										<view class="vip-discount" v-if="item.vip_online_state==1&&vip&&vip.discount!=1">
											{{vip.discount?(vip.discount * 100)/10:""}}折
										</view>
									</block>
								</block>
							</view>
						</view>
					</block>
				</view>

				<!-- 优惠信息 -->
				<view class="settlement-list-box">
					<view class="settlement-list">
						<view class="settlement-list-title">
							<text>会员价&折扣：</text>
						</view>
						<text class="settlement-list-price">{{disMoney?disMoney:0}}元</text>
					</view>
					<view class="settlement-list" @tap="couponFun" v-if="!card_type&&!buy_plus_type">
						<view class="settlement-list-title">
							<text>优惠券</text>
						</view>
						<view class="settlement-list-choose">
							<text class="settlement-list-price" v-if="coupon">-{{coupon.reduce_money}}元</text>
							<text v-if="!coupon">选择优惠券</text>
							<image class="settlement-list-choose-right" src="/static/images/arrow-right-1.png"></image>
						</view>
					</view>
					<view class="settlement-list">
						<view class="settlement-distance" @tap.stop="toShowOrHidedisrule">
							<image src="/static/images/rule.png"></image>
							<text>计价规则</text>
						</view>
						<view>
							<text>已优惠</text>
							<text class="settlement-list-price">￥{{disAllMoney}}</text>
						</view>
						<view>
							<text>小计</text>
							<text class="settlement-list-price">￥{{payMoney}}</text>
						</view>
					</view>
				</view>

				<!-- 留言 -->
				<view class="settlement-list-box">
					<view class="settlement-list">
						<text>给卖家留言</text>
						<text class="more-remark">最多100字</text>
					</view>
					<textarea maxlength="100" placeholder="留言" v-model="remark" class="textarea-t" :always-embed="true" placeholder-class="textarea-p"
						cursor-spacing="0"></textarea>
				</view>

			</view>
		</scroll-view>
		<!-- 底部 -->
		<view class="settlement-footer" :style="footerStyle">
			<view class="settlement-footer-left">
				<view class="settlement-footer-left-all">
					<text>合计:</text>
					<text>￥{{payMoney}}</text>
					<block v-if="is_integral_cash==1&&merchantConfig.marketing_methods==2&&integral_dis_num>0">
						<text class="integral-dis-num">+{{integral_dis_num}}{{integral_name}}</text>
					</block>
				</view>
				<view v-if="disMoney>0" class="settlement-footer-left-all">
					<text>已优惠:</text>
					<text>￥{{disAllMoney}}</text>
				</view>
			</view>
			<view @click="payBtn" class="report-submit">
				<view class="settlement-pay-btn" v-if="canClick&&goodsList.length>0">提交订单</view>
				<view class="settlement-pay-btn settlement-pay-btn-dis" v-else>提交订单</view>
			</view>
		</view>
		<!-- 优惠规则 -->
		<view class="settlement-model" v-if="showdisrule">
			<view class="settlement-model-inner show-dis-rule">
				<icon color="#999" type="cancel" @tap.stop="toShowOrHidedisrule"></icon>
				<view class="settlement-model-title">
					<text>计价规则</text>
				</view>
				<view class="settlement-rule">
					<view>1、活动商品不参加打折，活动优惠为商品原价减活动价。</view>
					<view>2、会员价商品计价方式为会员价×折扣，四舍五入到分(0.01元，不足1分算1分)，再乘以数量。</view>
					<view>3、普通商品计价方式为单价×折扣，四舍五入到分(0.01元，不足1分算1分)，再乘以数量。</view>
					<view>4、优惠券抵扣为计算其他优惠后、再计算优惠券满减。</view>
					<view>5、订单最终支付最少0.01元完成下单购买。</view>
				</view>
			</view>
		</view>
		<!-- plus会员注册提示 -->
		<view v-if="plus_shop_mask" class="plus-shop-mask">
			<view class="plus-shop-com">
				<view class="com-body">
					<view class="plus-title">
						<text>恭喜您，您购买成功后可以成为Plus会员，</text>
						<text>时长{{plus_time}}天，</text>
						<text>请输入基本信息完成购买</text>
					</view>
					<view class="plus-input">
						<input placeholder="输入您的姓名" maxlength="20" placeholder-class="pl" @input="getPlusName" :value="plusName"></input>
					</view>
					<view class="plus-input">
						<input placeholder="输入您的手机号码" maxlength="11" placeholder-class="pl" @input="getPlusPhone" :value="plusPhone"></input>
					</view>
				</view>
				<view class="plus-btn">
					<text class="plus-cancel" @tap="cancelPlus">放弃机会</text>
					<text class="plus-confirm" @tap="confirmPlus">确定</text>
				</view>
			</view>
		</view>

		<view class="livePlay" v-if="videoShow">
			<view class="closeIcon">
				<uni-icons style="margin-right:30rpx" type="close" size="18" @click="closeVedio"></uni-icons>
				<!-- <uni-icons type="download" size="18" @click="uploadVedio"></uni-icons> -->
			</view>
			<video id="myVideo" style="width: 100%;height: 95%;" :src="blessData.url" controls enable-play-gesture></video>
		</view>

	</view>
</template>

<script>
	// pages/Settlement/Settlement.js
	var app = getApp().globalData;
	const innerAudioContext = uni.createInnerAudioContext();
	const recorderManager = uni.getRecorderManager();
	import addressDiy from '@/components/address-diy.vue'
	import expressFee from '@/components/express-fee.vue'

	import {
		handleDownload
	} from '@/utils/downVedio.js'
	export default {
		components: {
			addressDiy,
			expressFee
		},
		data() {
			return {
				startDate: "",
				choose_send_time: '',
				//选择的配送时间
				choose_pick_time: '',
				//选择的自提时间
				multiArray: [
					['今天', '明天', '3-2', '3-3', '3-4', '3-5'],
					[0, 1, 2, 3, 4, 5, 6],
					[0, 10, 20]
				],
				//时间选择器里面的值
				multiIndex: [0, 0, 0],
				//被选中的时间下标
				address: {},
				goodsList: [],
				//购买的商品列表
				showPayPassword: false,
				lessmoney: 0,
				// 优惠券抵扣的金额。
				vip: '',
				status: 0,
				orderid: '',
				//订单id
				pickup_type: 0,
				pickup_list: [],
				integralid: 0,
				overflowmoney: 0,
				canClick: true,
				link_name: '',
				mobile_phone: null,
				distance: 0,
				delivery_fee: 0,
				//配送费
				actualMoney: 0,
				//实际总价
				payMoney: 0,
				//最终支付金额
				remark: '',
				showdisrule: false,
				user_type: 1,
				//用户的权益
				plus_shop_mask: false,
				plusPhone: null,
				//plus手机号
				plusName: '',
				//plus姓名
				wx_pay_money: '',
				//微信支付金额
				balance_pay_money: '',
				//余额支付的金额
				is_integral_cash: 0,
				//是否启用积分抵现
				integral_dis_num: 0,
				//积分抵现所用积分
				integral_dis_money: 0,
				//积分抵现能减少的金额、需要抵扣不足积分的金额（仅针对基于商品）
				max_use_integral: 0,
				//最多可用积分
				max_integral_dis_money: 0,
				//积分抵现最多能减少的金额、需要抵扣不足积分的金额（仅针对基于商品）
				difference_integral: 0,
				//不足积分差值（仅针对基于商品）
				merchantConfig: null,
				//商户配置
				business_state: 2,
				//关闭非营业时间下单
				business_time: [
					['08:30', '12:00'],
					['14:30', '22:45']
				], //营业时间
				is_upgrade: 0,
				//是否升级为plus会员
				disMoney: 0,
				//优惠金额
				disAllMoney: 0,
				//总优惠金额
				isPaySuccess: false,
				share_guide_id: null,
				//导购员id
				delivery_set: [0, 0, 0],
				isFocus: false,
				password: "",
				card_type: "",
				card_id: "",
				buy_plus_type: "",
				plus_act_id: "",
				plus_time: "",
				shopping_ids: "",
				coupon: "",
				send_time: [
					['09:00', '12:00'],
					['15:20', '19:00'],
					['22:00', '23:00']
				], //页面展示的商家可以配送的时间
				cacul_time: [], //用来计算的选择时间的数组
				math: '',
				starting_price: 0,
				isShowAddress: false,
				delivery_status: 0,
				delivery_cost: '',
				isShowFee: 1,
				distributor_id: '', // 分销员id
				imageValue: '', // 祝福语image
				blessinfo: {
					status: '0', // 权限
					entrance_style: '',
					privacy_statement: '',
				}, // 祝福语info
				blessData: {
					saveName: '',
					type: '',
					url: '',
					length: 0,
					storage_type: '',
				},
				isPlaying: false,
				doWays: ['操作', '删除'],
				waysIndex: 0,
				videoShow: false,
				powerLevel: '', // 配送等级
				entry_num_privacy: 0,
				send_delayed_time: 0,
				pickup_delayed_time: 0,
				auto_set_time: 1,
				isShowDialog: false, // 是否展示底部弹框
				userInfo: {},
				integral_name:''
			};
		},
		computed: {
			footerStyle() {
				let h = this.$store.bottomHeight + 100
				return 'height:' + h + 'rpx;padding-bottom:' + this.$store.bottomHeight + 'rpx';
			},
		},
		onReady() {
			this.videoContext = uni.createVideoContext('myVideo')
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		async onLoad(options) {
			await this.$onLaunched;
			this.integral_name = this.$store.integral_name;
			if (options && options.share_guide_id) {
				this.setData({
					share_guide_id: options.share_guide_id
				});
			}

			if (options && options.card_type && options.card_id) {
				this.setData({
					card_type: options.card_type,
					card_id: options.card_id,
				});
			}

			if (options && options.buy_plus_type && options.plus_act_id && options.plus_time) {
				this.setData({
					buy_plus_type: options.buy_plus_type,
					plus_act_id: options.plus_act_id,
					plus_time: options.plus_time
				});
			}
			if (options && options.distributor_id) {
				this.setData({
					distributor_id: options.distributor_id
				});
			}

			if (getApp().globalData.XcxData.systemInfo.platform == 'ios') {
				this.setData({
					textPadding: '10rpx'
				});
			}

			uni.removeStorageSync('shoppingAddress');
			uni.removeStorageSync('useCoupon');
			uni.removeStorageSync('blessData')
			let userInfo = uni.getStorageSync('userInfo')
			var shopping_ids = options.shopping_ids;
			this.setData({
				shopping_ids: shopping_ids,
				userInfo: userInfo ? userInfo : {}
			});

			if (!shopping_ids) {
				uni.showToast({
					title: '您未选择结算商品',
					mask: true,
					duration: 800
				});
			}

			var that = this;
			var shopping_ids = this.shopping_ids;
			this.getBuyData(shopping_ids)
			uni.removeStorageSync('storeShoppingCarIds');
		},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			let params = uni.getStorageSync('blessData')
			var address = uni.getStorageSync('shoppingAddress');
			var coupon = uni.getStorageSync('useCoupon');
			let delivery_set = this.delivery_set
			this.isPlaying = false
			if (params) {
				params = JSON.parse(params)
				this.$set(this.blessData, 'saveName', params.url);
				this.$set(this.blessData, 'storage_type', params.storageType);
				this.$set(this.blessData, 'type', params.type);
				this.$set(this.blessData, 'url', params.address);
				this.$set(this.blessData, 'length', params.audio_length);
			}
			this.setData({
				coupon: coupon ? coupon : '',
				isShowAddress: true,
				blessData: this.blessData,
				address: address ? address : {}
			});
			this.$forceUpdate()
			var that = this;
			app.sendRequest({
				url: '/Pay/getUserDetail',
				type: "post",
				showLoading: false,
				data: {},
				success: (res) => {
					if (res.status == 1) {
						var obj = {
							vip: res.vip_data
						};
					} else {
						var obj = {
							vip: null
						};
					}

					this.setData(obj); //计算最大积分抵扣
					this.calculationIntegralCash(() => {
						if (Object.keys(this.address).length != 0 && (that.pickup_type == 2 || that.pickup_type == 3)) {
							this.range(() => {
								that.calculateAllMoney();
							});
						} else {
							that.calculateAllMoney();
						}
					});
				}
			});
		},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {
			this.setData({
				isShowAddress: false
			})
		},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {
			uni.removeStorageSync('shoppingAddress');
			uni.removeStorageSync('useCoupon');
			if (!this.isPaySuccess && this.order_no) {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认取消该订单？',
					showCancel: true,
					cancelText: '取消订单',
					confirmText: '待会儿付',
					confirmColor: '#ff5c6d',
					success: function(res) {
						if (!res.confirm) {
							getApp().globalData.sendRequest({
								url: '/Order/cancelPay',
								data: {
									order_no: that.order_no
								},
								success: function(res) {}
							});
						}
					}
				});
			}
		},
		methods: {
			getBuyData(shopping_ids) {
				let that = this
				that.integral_name = this.$store.integral_name;
				getApp().globalData.sendRequest({
					url: '/Pay/getPayInfo_v5',
					type: "post",
					data: {
						id: shopping_ids,
					},
					success: async (res) => {

						if (res.status == 1) {
							if (res.data.storeSet.blessing_status) {
								// 获取祝福语权限
								that.getBlessPower()
							}
							if (res.data.merchantConfig && !that.buy_plus_type && !that.card_type && !that
								.card_id) {
								that.setData({
									merchantConfig: res.data.merchantConfig,
								})
								if (res.data.merchantConfig.integral_arrive_cash == 1 && res.user_type != 1) {
									that.setData({
										is_integral_cash: 1,
									})
								}
							}

							if (res.data.delivery_set[0] == 1) {
								that.setData({
									canClick: true,
								})
							}

							let address = that.address.id ? that.address : (res.data.address ? res.data.address : {});
							uni.setStorageSync('shoppingAddress', Object.keys(address).length != 0 ? address : '')
							that.setData({
								goodsList: res.data.goods,
								actualMoney: res.data.all_money,
								disMoney: res.data.dis_money,
								disAllMoney: res.data.dis_money,
								send_time: res.data.storeSet.new_business, //配送时间
								business_time: res.data.storeSet.new_business_time, //营业时间
								math: res.data.storeSet.service_radius,
								starting_price: res.data.storeSet.starting_price,
								business_state: res.data.storeSet.business_non_order,
								delivery_set: res.data.delivery_set,
								link_name: res.data.link_name,
								mobile_phone: res.data.mobile_phone,
								address: address,
								vip: res.data.vip_data ? res.data.vip_data : '',
								delivery_status: res.delivery_status,
								delivery_cost: res.delivery_cost,
								send_delayed_time: res.data.storeSet.send_delayed_time,
								pickup_delayed_time: res.data.storeSet.pickup_delayed_time,
								auto_set_time: res.data.storeSet.auto_set_time
							});
							// 自动选择时间

							that.pickup_type = await that.sendPowerLevel(res.data.delivery_set)
							that.auto_set_time == 1 && await that.selectTime();

							if (Object.keys(address).length != 0 && (that.pickup_type == 2 || that.pickup_type == 3)) {
								that.range(() => {
									if (that.vip) {
										that.calculationIntegralCash(() => {
											that.calculateAllMoney();
										});
									} else {
										that.calculateAllMoney();
									}
								});
							} else {
								if (that.vip) {
									that.calculationIntegralCash(() => {
										that.calculateAllMoney();
									});
								} else {
									that.calculateAllMoney();
								}
							}
						} else {
							that.setData({
								disMoney: '0.00',
								goodsList: []
							});
						}
					}
				});

			},
			// 配送等级权限
			sendPowerLevel(delivery_set) {
				const that = this
				let pickup_type = 0
				return new Promise((resolve) => {
					app.sendRequest({
						url: '/MerInterface/storeConfigInfo',
						success: function({
							status,
							message,
							data
						}) {
							if (status == 1) {
								if (!data || !data.distribution_json) {
									that.pickup_list = [{
											name: '门店发货',
											id: 3
										},
										{
											name: '同城配送',
											id: 2
										}, {
											name: '门店自提',
											id: 1
										},
									]
								} else {
									that.pickup_list = JSON.parse(data.distribution_json)
								}
								that.pickup_list = that.pickup_list.filter(x => {
									return (delivery_set[x.id - 1] > 0)
								})
								pickup_type = that.pickup_list[0].id
								resolve(pickup_type)
							} else {
								uni.showToast({
									title: message,
									icon: 'none'
								})
							}
						}
					})

				})

			},


			// 修改选择时间
			selectTime() {
				let date_params = {
					detail: {
						value: [0, 0, 0]
					}
				}
				this.pickerTap()
				this.bindStartMultiPickerChange(
					date_params
				)
			},

			// 支付宝小程序选择时间
			showSelectTime() {
				this.$refs.popup.open('bottom')
			},

			// 上传祝福语
			toBlessing() {
				if (this.entry_num_privacy == 0) {
					this.entry_num_privacy++
					uni.navigateTo({
						url: '/pages/order/privacyStatement/privacyStatement?info=' + this.blessinfo.privacy_statement
					})
				} else {
					uni.navigateTo({
						url: '/pages/order/selectBlessingWays/selectBlessingWays'
					})
				}

			},


			// 编辑
			toEdit(type) {
				type == 2 ? this.toStop() : this.closeVedio()
				let blessData = uni.getStorageSync('blessData')
				if (blessData) {
					blessData = Object.assign(JSON.parse(blessData), {
						flag: 'isEdit'
					})

				}
				uni.navigateTo({
					url: '/pages/order/selectBlessingWays/selectBlessingWays?blessData=' + JSON.stringify(blessData)
				})
			},

			// 关闭视频
			closeVedio() {
				this.videoContext.stop()
				this.isPlaying = false
				this.videoShow = false
			},

			// 下载视频
			uploadVedio() {
				handleDownload(this.blessData.url)
			},

			// 删除
			async deleteItem(type) {
				type == 1 ? this.closeVedio() : this.toStop()
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定要删除祝福吗?',
					success: async (res) => {
						if (res.confirm) {
							let obj = {
								storage_type: that.blessData.storage_type,
								url: that.blessData.saveName
							}
							try {
								const res = await this.$request('Blessing/Applets/deleteBlessing', obj)
								if (res.status == 1) {
									uni.showToast({
										title: '删除成功',
									})
									that.videoShow = false
									that.blessData = {}
								}
								uni.removeStorageSync('blessData')
							} catch (err) {
								console.log(err)
							}
						}
					}
				})
			},

			// 播放
			toPlay(type) {
				let _this = this
				// 视频
				if (type == 1) {
					this.videoShow = true
					this.videoContext.play()
				} else {
					// 录音
					_this.isPlaying = true

					innerAudioContext.src = _this.blessData.url;
					innerAudioContext.play()
					innerAudioContext.onPlay(() => {
						innerAudioContext.onTimeUpdate(() => {
							_this.blessData.length = innerAudioContext.duration
						})
						setTimeout(() => {
							_this.blessData.length = innerAudioContext.duration
						}, 1000)
					})
					innerAudioContext.onEnded(() => {
						_this.isPlaying = false
					})
				}
			},

			// 播放暂停
			toStop() {
				innerAudioContext.pause()
				this.isPlaying = false
			},
			// 获取祝福语权限
			async getBlessPower() {
				try {
					const {
						data,
						status
					} = await this.$request('Blessing/Applets/privacyStatement')
					if (status == 1) {
						this.blessinfo = Object.assign({}, data)
					} else {
						uni.showToast({
							title: '获取祝福语权限失败',
							icon: 'none'
						})
					}
				} catch (err) {
					console.log(err)
				}
			},
			//积分抵现选择
			changeIntegralCash: function() {
				this.setData({
					is_integral_cash: this.is_integral_cash == 1 ? 0 : 1
				});
				this.calculateAllMoney(); //计算支付金额
			},
			//重新计算积分抵扣金额
			calculateIntegral: function() {
				var merchantConfig = this.merchantConfig;
				if (merchantConfig && merchantConfig.integral_arrive_cash == 1) {
					var integral_dis_money = app.roundPrice((this.integral_dis_num / (merchantConfig
						.integral_arrive_cash_data /
						merchantConfig.integral_arrive_cash_price)).toFixed(2));
					this.setData({
						integral_dis_money: integral_dis_money
					})
				}
			},
			//输入抵现积分
			inputIntegral: function(e) {
				var max_use_integral = this.max_use_integral;
				var integral_dis_num = e.detail.value;

				if (integral_dis_num > max_use_integral) {
					integral_dis_num = max_use_integral;
				}

				this.setData({
					is_integral_cash: integral_dis_num > 0 ? 1 : 0,
					integral_dis_num: integral_dis_num
				});
				this.calculateIntegral(); //计算积分抵现的金额

				this.calculateAllMoney(); //计算最后支付的金额与优惠
			},
			//点击显示规则
			toShowOrHidedisrule: function() {
				var showdisrule = this.showdisrule;
				this.setData({
					showdisrule: !showdisrule
				});
			},
			//输入自提姓名
			inputName: function(e) {
				this.setData({
					link_name: e.detail.value
				});
			},
			//输入自提手机号
			inputPhone: function(e) {
				let telReg = /^1[3456789]\d{9}$/
				if (!telReg.test(e.detail.value)) {
					this.canClick = false
					return;
				} else {
					this.setData({
						mobile_phone: e.detail.value,
						canClick: true
					});
				}

			},
			//查看商品详情
			toGoodsDetail: function(e) {
				var id = e.currentTarget.dataset.goods_id;
				uni.navigateTo({
					url: '/pages/product/details/details?id=' + id
				});
			},
			//计算最终支付价格
			calculateAllMoney: function(fn) {
				var payMoney = parseFloat(this.actualMoney);

				if (this.vip && this.merchantConfig && this.is_integral_cash == 0 && this.merchantConfig
					.integral_arrive_cash == 1 &&
					this.merchantConfig.marketing_methods == 2 && this.difference_integral > 0) {
					var goods = this.goodsList;
					payMoney = 0;

					for (var i = 0; i < goods.length; i++) {
						var price = goods[i].online_price;

						if (this.vip.user_type == 2 && goods[i].plus_mem_status == 1 && goods[i].plus_mem_integral ==
							0) {
							price = goods[i].plus_price;
						} else if (goods[i].shop_mem_status == 1 && goods[i].shop_mem_integral == 0) {
							price = goods[i].shop_mem_price;
						}

						if (goods[i].vip_online_state == 1) {
							price = getApp().globalData.roundPrice(price * this.vip.discount);
						}

						payMoney += getApp().globalData.roundPrice(price * goods[i].num);
					}
				}

				var coupon = this.coupon;
				var disAllMoney = parseFloat(this.disMoney);
				var delivery_fee = this.delivery_fee; //配送费

				var pickup_type = this.pickup_type; //配送方式 1自提  2同城配送  3快递发货
				let deliveryMoney = payMoney; //是否达到免运费金额，免运费规则刨除优惠券金额+积分抵扣金额
				if (coupon) {
					payMoney = getApp().globalData.roundPrice(payMoney - coupon.reduce_money);
					disAllMoney = getApp().globalData.roundPrice(disAllMoney + parseFloat(coupon.reduce_money));
				}

				var is_integral_cash = this.is_integral_cash; //是否开启积分抵现
				if (is_integral_cash == 1) {
					var integral_dis_money = this.integral_dis_money; //积分抵扣的金额

					if (this.merchantConfig.marketing_methods == 1) {
						payMoney = getApp().globalData.roundPrice(payMoney - integral_dis_money);
					} else {
						payMoney = getApp().globalData.roundPrice(payMoney + integral_dis_money);
						deliveryMoney = getApp().globalData.roundPrice(deliveryMoney + integral_dis_money);
					}
				}

				if (pickup_type == 2 || pickup_type == 3) {
					//商家配送
					if (this.delivery_status == 1 && parseFloat(deliveryMoney) >= parseFloat(this.delivery_cost)) {
						delivery_fee = 0;
						this.isShowFee = 2;
					} else {
						this.isShowFee = 1;
					}
					payMoney = parseFloat((parseFloat(payMoney) + parseFloat(delivery_fee)).toFixed(2));
				}
				var starting_price = getApp().globalData.roundPrice(this.starting_price - payMoney);
				var canClick = true;

				if (starting_price > 0 && (pickup_type == 2 || [1, 2, 3].indexOf(pickup_type) == -1)) {
					canClick = false;
				}

				if ((pickup_type == 2 || pickup_type == 3) && Object.keys(this.address).length == 0) {
					canClick = false
				}

				this.setData({
					disAllMoney: disAllMoney,
					payMoney: payMoney,
					canClick: canClick
				});

				if (typeof fn == "function") {
					fn();
				}
			},
			//计算最多能使用的积分和最多能抵扣的金额
			calculationIntegralCash: function(fn) {
				var config = this.merchantConfig;
				var vip = this.vip;
				var max_integral_dis_money = 0; //最大使用积分能抵扣的金额（仅针对基于订单）、需要抵扣不足积分的金额（仅针对基于商品）

				var max_use_integral = 0; //最大使用积分

				var difference_integral = 0; //不足积分差值（仅针对基于商品）
				// debugger
				if (config && config.integral_arrive_cash == 1 && vip) {
					if (config.marketing_methods == 1) {
						//基于订单
						var actualMoney = this.actualMoney; //原应支付金额

						var coupon = this.coupon; //优惠券

						if (coupon && coupon.reduce_money) {
							actualMoney = getApp().globalData.roundPrice(actualMoney - coupon.reduce_money); //减掉优惠券金额
						}

						max_integral_dis_money = getApp().globalData.roundPrice(config.integral_arrive_cash_rate *
							actualMoney);
						max_use_integral = Math.round((config.integral_arrive_cash_data * max_integral_dis_money /
								config
								.integral_arrive_cash_price)
							.toFixed(0));

						if (vip.integral * 1 < max_use_integral) {
							max_use_integral = vip.integral;
							max_integral_dis_money = getApp().globalData.roundPrice(max_use_integral * config
								.integral_arrive_cash_price /
								config.integral_arrive_cash_data);
						}

					} else {
						//基于商品
						var goods = this.goodsList;

						for (var i = 0; i < goods.length; i++) {
							if (vip.user_type == 2 && goods[i].plus_mem_status == 1) {
								if (goods[i].plus_mem_integral * 1 > 0) {
									max_use_integral += goods[i].plus_mem_integral * goods[i].num;
								}
							} else if (goods[i].shop_mem_status == 1 && goods[i].shop_mem_integral * 1 > 0) {
								max_use_integral += goods[i].shop_mem_integral * goods[i].num;
							}
						}

						if (vip.integral * 1 < max_use_integral) {
							difference_integral = getApp().globalData.roundPrice(max_use_integral - vip.integral);
							max_use_integral = vip.integral * 1;
							max_integral_dis_money = getApp().globalData.roundPrice(difference_integral * config
								.integral_arrive_cash_price /
								config.integral_arrive_cash_data);
						}
					}
				}
				this.setData({
					max_use_integral: max_use_integral,
					max_integral_dis_money: max_integral_dis_money,
					integral_dis_num: max_use_integral,
					integral_dis_money: max_integral_dis_money,
					is_integral_cash: this.vip && this.vip.user_type != 1 && (max_use_integral > 0 ||
						difference_integral > 0) ? 1 : 0,
					difference_integral: difference_integral,
				});
				if (typeof fn == "function") {
					fn();
				}
			},
			//选择配送方式
			sendMethod: function(e) {
				var index = e.currentTarget.dataset.index;
				this.setData({
					pickup_type: parseInt(index),
					startDate: index == 2 ? this.choose_send_time : this.choose_pick_time,
				});

				if (index == 1) {
					this.setData({
						canClick: true
					});
				}

				if (index == 2 || index == 3) {
					if (Object.keys(this.address).length != 0) {
						this.range(() => {
							this.calculateAllMoney();
						});
					} else {
						this.setData({
							canClick: false
						});
					}
				} else {
					this.calculateAllMoney();
				}

				// 重新选择时间
				this.auto_set_time == 1 && this.selectTime()
			},

			//密码框聚焦input
			set_Focus() {
				this.setData({
					isFocus: true
				});
			},
			//选择优惠券
			couponFun: function() {
				uni.navigateTo({
					url: '/pages/index/useCoupon/useCoupon?money=' + this.actualMoney + "&shopping_ids=" + this.shopping_ids + "&is_integral_cash=" +
						this.is_integral_cash + '&scene_type=1'
				});
			},
			//取消输入会员密码
			cancelPassword: function() {
				this.setData({
					showPayPassword: false,
					password: '',
					canClick: true,
					isPaySuccess: true
				});
				uni.redirectTo({
					url: '/pages/myOrder/myOrder?nav=-1',
				});
			},
			//确认下单
			payBtn: function() {

				console.log('payBtn')
				if (!this.canClick) {
					return;
				}
				var business_state = this.business_state; //是否开启非营业时间下单
				var send_time = this.business_time;

				if (business_state == 2) {
					//选取配送时间的开始时刻和结束时刻
					let start = send_time[0][0];
					let end = send_time[send_time.length - 1][1];
					let checktime = start + '-' + end;
					if (!getApp().globalData.checkTime(checktime)) {
						uni.showModal({
							title: '提示',
							content: '当前时间不在今日营业时间范围内',
							showCancel: false
						});
						return;
					}
				}

				if (this.pickup_type == 2) {
					var dateTips = '请选择起送时间';
				} else if (this.pickup_type == 1) {
					var dateTips = '请选择自提时间';
				} else if (this.pickup_type != 3) {
					uni.showToast({
						title: '商家暂不支持下单',
						icon: 'none',
						duration: 1000,
						mask: false
					});
					return;
				}

				var startDate = this.startDate;

				if ((startDate == "" || startDate == 'undefined') && this.pickup_type != 3) {
					uni.showToast({
						title: dateTips,
						icon: 'none',
						duration: 1000,
						mask: false
					});
					return;
				}

				var pickup_type = this.pickup_type;
				var address = this.address;
				var link_name = this.link_name;
				var mobile_phone = this.mobile_phone;

				if (pickup_type == 2 || pickup_type == 3) {
					if (Object.keys(this.address).length == 0) {
						uni.showToast({
							title: '请选择收货地址',
							image: "/static/images/tip.png",
							duration: 800,
							mask: true
						});
						return;
					}
				} else {
					if (!link_name || !link_name.length || !link_name.trim().length) {
						uni.showToast({
							title: '请填写姓名',
							image: "/static/images/tip.png",
							duration: 800,
							mask: true
						});
						return;
					}

					var reg = /^1[3456789]\d{9}$/;

					if (!mobile_phone.match(reg)) {
						uni.showToast({
							title: '请完善手机号',
							image: "/static/images/tip.png",
							duration: 800,
							mask: true
						});
						return;
					}
				}

				if (this.is_integral_cash == 1 && this.merchantConfig.marketing_methods == 2 && this.integral_dis_money > 0) {
					var integral = this.merchantConfig.integral_arrive_cash_data;
					var price = this.merchantConfig.integral_arrive_cash_price;
					uni.showModal({
						title: this.integral_name+'不足提示',
						content: `您的剩余${this.integral_name}不足，还差${this.difference_integral}${this.integral_name}，是否确定使用金额抵扣（${price}元=${integral}${this.integral_name}），放弃则使用商城原价购买`,
						cancelColor: '#999',
						cancelText: '放弃',
						confirmColor: '#ff5c6d',
						confirmText: '确定',
						showCancel: true,
						success: result => {
							if (result.confirm) {
								this.order();
							} else {
								this.setData({
									is_integral_cash: 0
								});
								this.calculateAllMoney(res => {
									this.order();
								});
							}
						}
					});
				} else {
					if (this.buy_plus_type > 0) {
						//购买商品成为plus会员
						this.setData({
							plus_shop_mask: true
						})
					} else {
						this.order();
					}
				}

			},
			//输入plus手机号
			getPlusPhone: function(e) {
				if (!(/^1[3456789]\d{9}$/).test(e.detail.value)) {
					uni.showToast({
						title: dateTips,
						icon: 'none',
						duration: 1000,
						mask: false
					});
					return;
				} else {
					this.setData({
						plusPhone: e.detail.value
					});
				}

			},
			//输入plus姓名
			getPlusName: function(e) {
				this.setData({
					plusName: e.detail.value
				});
			},
			//隐藏注册plus会员输入信息弹框
			cancelPlus: function() {
				this.setData({
					plus_shop_mask: false,
					plusPhone: '',
					plusName: '',
					is_upgrade: 0
				});
				this.order();
			},
			//确认注册plus会员并下单按钮
			confirmPlus: function() {
				var that = this;
				var plusPhone = that.plusPhone;
				var plusName = that.plusName;
				var reg = /^1[3456789]\d{9}$/;

				if (!plusPhone.match(reg)) {
					uni.showToast({
						title: '请完善手机号',
						image: "/static/images/tip.png",
						duration: 800,
						mask: true
					});
					return;
				}

				if (!plusName || plusName == '') {
					uni.showToast({
						title: '请输入姓名',
						duration: 800,
						mask: true
					});
					return;
				}

				this.setData({
					plus_shop_mask: false,
					is_upgrade: 1
				});
				this.order();
			},
			// 支付下单
			order: function() {
				this.setData({
					canClick: false
				});
				var address_id = this.address.id;
				var coupon = this.coupon;
				var coupon_type = 1;

				if (coupon) {
					var coupon_id = coupon.id;
					coupon_type = coupon.couponType;
				} else {
					var coupon_id = '';
					coupon_type = '';
				}

				var that = this;
				var thisYears = new Date().getFullYear();
				var pickup_type = this.pickup_type;

				if (pickup_type == 1) {
					address_id = '';
				}

				var startDate = this.startDate; //时间

				if (pickup_type == 3) {
					startDate = '';
				} else {
					startDate = startDate.replace("月", "-");
					startDate = startDate.replace("日", " ");
					startDate = thisYears + "-" + startDate + ":00";
				}

				uni.showLoading({
					title: '提交订单中...',
					// #ifndef MP-ALIPAY
					mask: true,
					// #endif
				});
				var delivery_fee = this.delivery_fee;
				var is_integral_cash = this.is_integral_cash; //是否启用积分抵现

				var integral_dis_money = is_integral_cash == 1 ? this.integral_dis_money : 0; //积分抵扣的金额

				var integral_dis_num = is_integral_cash == 1 ? this.integral_dis_num : 0; //积分抵现使用的积分

				getApp().globalData.sendRequest({
					url: '/Pay/placeOrder_v7',
					type: "post",
					showLoading: false,
					data: {
						distributor_id: that.distributor_id,
						address_id: address_id,
						pickup_type: pickup_type,
						coupon_id: coupon_id,
						coupon_type: coupon_type,
						shopping_ids: that.shopping_ids,
						mobile_phone: that.mobile_phone,
						link_name: that.link_name,
						delivery_fee: delivery_fee,
						remark: that.remark,
						all_money: that.payMoney,
						dis_money: that.disMoney,
						start_date: startDate,
						is_integral_cash: is_integral_cash,
						integral_dis_money: integral_dis_money,
						integral_dis_num: integral_dis_num,
						plus_phone: this.plusPhone,
						plus_name: this.plusName,
						is_upgrade: this.is_upgrade,
						share_guide_id: this.share_guide_id,
						card_type: this.card_type ? this.card_type : '',
						card_id: this.card_id ? this.card_id : '',
						buy_plus_type: this.buy_plus_type ? this.buy_plus_type : '',
						plus_act_id: this.plus_act_id ? this.plus_act_id : '',
					},
					success: async function(res) {
						uni.hideLoading();
						if (res.status == 1) {
							uni.redirectTo({
								url: '/pages/order/waitPay/waitPay?order_no=' + res.data
									.order_no + '&money=' + res.data.allMoney
							});
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 1500
							});
							that.setData({
								canClick: true
							});
						}
					}
				});
			},
			//获取配送费
			range: function(fn) {
				var that = this;
				var address = this.address;
				if (!this.address.id) {
					typeof fn == "function" && fn();
					return;
				}
				getApp().globalData.sendRequest({
					url: '/Address/range_v2',
					type: "post",
					data: {
						address_id: address.id,
						order_genre: 1,
						//普通订单
						shopping_ids: this.shopping_ids,
						pickup_type: this.pickup_type
					},
					success: function(res) {

						if (res.status == 1) {
							that.setData({
								delivery_fee: res.fee,
								distance: that.pickup_type == 2 ? res.distance : 0
							});

							if (typeof fn == "function") {
								fn();
							}
						} else {
							uni.showToast({
								title: res.msg ? ('地址: ' + res.msg) : '收货地址不在配送范围内',
								icon: 'none',
								duration: 1500,
								mask: false
							});
							that.setData({
								canClick: false,
								delivery_fee: 0,
								distance: res.distance ? res.distance : 0
							});
							if (typeof fn == "function") {
								fn();
							}
						}
					}
				});
			},

			//点击时间选择器
			pickerTap: function() {
				console.log(this.business_time, 'this.business_time')
				this.setData({
					cacul_time: this.pickup_type == 2 ? app.handleTimeArr(this.send_time) : app.handleTimeArr(
						this.business_time)
				})
				this.loadMonthDate(); //生成可选月日
				this.loadHours(); //生成可选时
				this.loadMinutes(); //生成可选分
			},

			//修改时间选择器的列
			bindMultiPickerColumnChange: function(e) {
				var multiIndex = this.multiIndex; // 把选择的对应值赋值给 multiIndex=[0,0,0]
				multiIndex[e.detail.column] = e.detail.value; // 然后再判断当前改变的是哪一列,如果是第1列改变
				if (e.detail.column === 0) {
					//日期列改变
					multiIndex[1] = 0;
					multiIndex[2] = 0;
					this.setData({
						multiIndex: multiIndex
					});
					this.loadHours();
					this.loadMinutes();
				} else if (e.detail.column === 1) {
					// 如果是第2列 小时改变
					multiIndex[2] = 0;
					this.setData({
						multiIndex: multiIndex
					});
					this.loadMinutes();
				}
			},

			//确认修改时间
			bindStartMultiPickerChange: function(e) {
				var monthDay = this.multiArray[0][e.detail.value[0]];
				var hours = this.multiArray[1][e.detail.value[1]];
				var minute = this.multiArray[2][e.detail.value[2]];
				if (monthDay === "今天") {
					var month = new Date().getMonth() + 1;
					var day = new Date().getDate();
					monthDay = month + "月" + day + "日";
				} else if (monthDay === "明天") {
					var date1 = new Date();
					date1.setDate(new Date().getDate() + 1);
					monthDay = date1.getMonth() + 1 + "月" + date1.getDate() + "日";
				} else {
					var month = monthDay.split("-")[0]; // 返回月

					var day = monthDay.split("-")[1]; // 返回日

					monthDay = month + "月" + day + "日";
				}

				var startDate = monthDay + " " + hours + ":" + minute;
				var obj = {
					startDate: startDate
				};
				if (this.pickup_type == 2) {
					//配送
					this.setData({
						startDate: obj.startDate,
						choose_send_time: obj.startDate,
						multiIndex: e.detail.value
					});
				} else {
					//自提
					this.setData({
						startDate: obj.startDate,
						choose_pick_time: obj.startDate,
						multiIndex: e.detail.value
					});
				}
				console.log(this.startDate, this.choose_pick_time, 999)
			},



			//生成可选月日
			loadMonthDate: function() {
				var multiArray = this.multiArray;
				let delay_time = this.pickup_type == 2 ? (this.send_delayed_time * 60) : (this.pickup_delayed_time *
					60)
				multiArray[0] = app.createMonthDay(this.cacul_time, delay_time);
				this.setData({
					multiArray: multiArray
				});
				this.$forceUpdate()
			},

			//生成可选时
			loadHours: function() {
				var multiArray = this.multiArray;
				let delay_time = this.pickup_type == 2 ? (this.send_delayed_time * 60) : (this.pickup_delayed_time *
					60)
				multiArray[1] = app.createHours(this.cacul_time, this.multiArray, this.multiIndex, delay_time);
				this.setData({
					multiArray: multiArray
				});
				this.$forceUpdate()
			},

			//生成可选分
			loadMinutes() {
				var multiArray = this.multiArray;
				let delay_time = this.pickup_type == 2 ? (this.send_delayed_time * 60) : (this.pickup_delayed_time * 60)
				multiArray[2] = app.createMinutes(this.cacul_time, multiArray, this.multiIndex, delay_time);
				this.setData({
					multiArray: multiArray
				});
				this.$forceUpdate()
			},

			//支付成功
			paySuccess: function() {
				this.setData({
					isPaySuccess: true
				});
				uni.redirectTo({
					url: "/pages/order/paySuccess/paySuccess?money=" + this.payMoney + "&order_no=" + this.order_no +
						"&pick_code=" + this.pick_code
				});
			},



			// 关闭选择时间筛选框
			closeSelect() {
				this.$refs.popup.close()
			},

			// 完成时间筛选框
			successSelect() {
				this.$refs.popup.close()
			}


		}
	};
</script>
<style>
	@import "./Settlement.css";
</style>
<style lang="less" scoped>
	.settlement-list-choose {
		.select-time {
			color: #ff5c6d;
		}

		/deep/.uni-popup {
			background-color: #fff;

			.uni-transition {
				background-color: #fff;

				.uni-popup__wrapper-box {
					background-color: #fff;

					.operate {
						display: flex;
						justify-content: flex-end;
						align-items: center;
						padding: 10px 20px 0 20px;
						position: absolute;
						z-index: 9999;
						width: 100%;
						box-sizing: border-box;

						.sure {
							color: #07c160;
						}
					}
				}
			}
		}
	}
</style>
